var o = require("./configs/shopConfig.js"), i = require("./configs/newShopConfig.js"),
    a = require("./configs/activityAndTaskConfig.js"), r = require("./configs/activityConfig.js"),
    s = require("./configs/npcBubbleConfig.js"), l = require("./configs/randomChatConfig.js"),
    c = require("./configs/adCrossListConfig.js"), d = function () {
    };
d.prototype = {
    _shopConf: null,
    _activityAndTaskConf: null,
    _activity: null,
    _UISwitchConf: null,
    _npcBubbleConf: null,
    _randomChatConf: null,
    ctor: function () {
        this._cdnUrl = Global.config.resUrl, this.setDefaultConfig(), this.initShopConf(),
            this.initActivityAndTaskConf(), this.initActivityConf(), this.initUISwitchConf(),
            this.initNPCBubbleConf(), this.initRandomChatConf(), this.initAdCrossListConf();
    },
    setDefaultConfig: function () {
        this.defaultConfigs = {}, this.defaultConfigs.shopIds = i, this.defaultConfigs.shop = o,
            this.defaultConfigs.activityAndTask = a, this.defaultConfigs.activity = r, this.defaultConfigs.npcBubble = s,
            this.defaultConfigs.randomChat = l, this.defaultConfigs.adCrossList = c;
    },
    getDefaultConfig: function (e) {
        return this.defaultConfigs && this.defaultConfigs[e] ? this.defaultConfigs[e] : null;
    },
    initShopConf: function () {
        var e, t = this, n = this.getDefaultConfig("shop"), o = this._cdnUrl + "/shopConfig.json";
        e = cc.sys.now();
        this.getConf(o, e, function (e) {
            console.log("拉取配置成功"), t._shopConf = e;
        }, function () {
            console.log("拉取配置失败"), t._shopConf = n;
        });
    },
    initShopIdsConf: function () {
        var e, t = this, n = this.getDefaultConfig("shopIds"), o = this._cdnUrl + "/newShopConfig.json";
        e = cc.sys.now();
        this.getConf(o, e, function (e) {
            console.log("拉取配置成功"), t._shopIdsConf = e;
        }, function () {
            console.log("拉取配置失败"), t._shopIdsConf = n;
        });
    },
    initActivityAndTaskConf: function () {
        var e, t = this, n = this.getDefaultConfig("activityAndTask"),
            o = this._cdnUrl + "/activityAndTaskConfig.json";
        e = cc.sys.now();
        this.getConf(o, e, function (e) {
            t._activityAndTaskConf = e;
        }, function () {
            t._activityAndTaskConf = n;
        });
    },
    initActivityConf: function () {
        var e, t = this, n = this.getDefaultConfig("activity"), o = this._cdnUrl + "/activityConfig.json";
        e = cc.sys.now();
        this.getConf(o, e, function (e) {
            t._activityConf = e;
        }, function () {
            t._activityConf = n;
        });
    },
    initUISwitchConf: function () {
        var e, t = this, n = this._cdnUrl + "/UIConfig.json";
        e = cc.sys.now();
        this.getConf(n, e, function (e) {
            t._UISwitchConf = e.data[0], console.log("self._UISwitchConf: ", e);
        }, function () {
            t._UISwitchConf = null, console.log("self._UISwitchConf= null");
        });
    },
    initNPCBubbleConf: function () {
        var e, t = this, n = this.getDefaultConfig("npcBubble"), o = this._cdnUrl + "/npcBubbleConfig.json";
        e = cc.sys.now();
        this.getConf(o, e, function (e) {
            t._npcBubbleConf = e;
        }, function () {
            t._npcBubbleConf = n;
        });
    },
    initRandomChatConf: function () {
        var e, t = this, n = this.getDefaultConfig("randomChat"), o = this._cdnUrl + "/randomChatConfig.json";
        e = cc.sys.now();
        this.getConf(o, e, function (e) {
            t._randomChatConf = e;
        }, function () {
            t._randomChatConf = n;
        });
    },
    initAdCrossListConf: function () {
        var e, t = this, n = this.getDefaultConfig("adCrossList"), o = this._cdnUrl + "/adCrossListConfig.json";
        e = cc.sys.now();
        this.getConf(o, e, function (e) {
            t._adCrossListConf = e;
        }, function () {
            t._adCrossListConf = n;
        });
    },
    getUISwitch: function () {
        return console.log("cdn config: ", this._UISwitchConf), !!this._UISwitchConf && 0 != Global.utils.compareVersion(this._UISwitchConf.trialVersion, Global.config.VERSION);
    },
    getUISwitchConf: function () {
        return this._UISwitchConf;
    },
    getShopConf: function () {
        return this._shopConf;
    },
    getNPCBubbleConf: function () {
        return this._npcBubbleConf;
    },
    getRandomChatConf: function () {
        return this._randomChatConf;
    },
    getShopIdsConf: function () {
        return this._shopIdsConf;
    },
    getActivityAndTaskConf: function () {
        return this._activityAndTaskConf;
    },
    getActivityConf: function () {
        return this._activityConf;
    },
    getAdCrossListConf: function () {
        return this._adCrossListConf;
    },
    _getData: function (e, t, n, o, i) {
        if (console.log("_getData data=", e[0], t, n, o, i), t < n / o) return e[i];
        var a = n;
        return e[--i] ? (n = e[i].rate + a, this._getData(e, t, n, o, i)) : (console.log("_getData error dataArr[index] =", e[i], i, e),
            null);
    },
    getConf: function (e, t, n, o) {
        Global.utils.httpRequest(e, t, n, o);
    }
}, module.exports = d
